package opera;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要借阅的书籍名：");
        String name = sc.nextLine();

        int currentSize = booklist.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBook(i);
            if(book.getName().equals(name) && !book.isBorrowed()){
                book.setBorrowed(true);
                System.out.println("借阅成功！");
                return ;
            }
        }

    }
}
